/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package horizon.gui.component;

import horizon.component.IRenderUpdate;
import horizon.util.Vector2;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;

/**
 *
 * @author J_Laptop
 */
public abstract class GuiComponent implements IRenderUpdate {

    Rectangle2D componentBox;
    Vector2 size;
    Vector2 position;
    String name;
    boolean inFocus = false;

    public GuiComponent(String name, Vector2 size, Vector2 position) {
        
        this.name = name;
        this.size = size;
        this.position = position;
        componentBox = new Rectangle(position.getPoint(), size.getDim());

    }

    public boolean isInFocus() {
        return inFocus;
    }

    public void setInFocus(boolean inFocus) {
        this.inFocus = inFocus;
    }
    
    

    public String getName() {
        return name;
    }

    public Vector2 getPosition() {
        return position;
    }

    public void setPosition(Vector2 position) {
        this.position = position;
        componentBox = new Rectangle(position.getPoint(), size.getDim());
    }

    public Vector2 getSize() {
        return size;
    }

    public void setSize(Vector2 size) {

        this.size = size;
        componentBox = new Rectangle(position.getPoint(), size.getDim());

    }
    
    public boolean isClicked(Point p){
        
        return componentBox.contains(p);
        
    }
    
    public void enterPressed(){
        
        
    }
    
    public abstract void onActivate(MouseEvent e);
    
    public void move(Vector2 v){
       
        setPosition(position.add(v));
        
        
    }
}
